package com.c5c7.servlet;


import com.c5c7.bean.NewsBean;
import com.c5c7.dao.NewsDao;
import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;

import java.io.IOException;

@WebServlet("/newsDetail.html")
public class NewsDetailServlet  extends HttpServlet {
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String newsID = req.getParameter("newsID");
        int id = Integer.parseInt(newsID);
        NewsBean newsBean = (new NewsDao()).getNewsByID(id);
        req.setAttribute("title",newsBean.getNewsTitle());
        req.setAttribute("content",newsBean.getNewsContent());
        req.getRequestDispatcher("/newsFrontDetail.jsp").forward(req,resp);
    }
}
